package net.forty2ware.vintagesofa

import org.apache.commons.lang.builder.EqualsBuilder
import org.apache.commons.lang.builder.HashCodeBuilder

// http://wiki.apache.org/couchdb/HTTP_view_API
class View {
  def name
  def mapFunction
  def reductionFunction

  def query(map) {
    /*
      key=keyvalue
      startkey=keyvalue
      startkey_docid=docid
      endkey=keyvalue
      endkey_docid=docid
      limit=max rows to return This used to be called "count" previous to Trunk SVN r731159
      stale=ok
      descending=true
      skip=number of rows to skip
      group=true Version 0.8.0 and forward
      group_level=int
      reduce=false Trunk only (0.9)
      include_docs=true Trunk only (0.9)
    */

    return []
  }

  @Override
  public boolean equals(Object o) {
    if (o == null) { return false; }
    if (o == this) { return true; }
    if (obj.getClass() != getClass()) {
      return false;
    }

    View rhs = (View)o;
    return new EqualsBuilder()
      .append(name, rhs.name)
      .isEquals()
  } 

  @Override
  public int hashCode() {
    return new HashCodeBuilder(9, 53)
      .append(name)
      .toHashCode()
  }

}
